<?php include_once('header.php'); ?>
<?php include_once('left_navigation.php'); 
 define('SITE_URL', 'http://localhost/vipin/');
?>	
<div class="col-lg-12"><!-- Start Middle Content Div-->
    <div class="box">
        <div class="box-header" data-original-title=""><!-- Start Box Header Div-->
            <h2><i class="fa fa-edit"></i><span class="break"></span>Items Description</h2>
            <div class="box-icon">
                <a href="gallery.html#" class="btn-minimize"><i class="fa fa-chevron-up"></i></a>
                <a href="gallery.html#" class="btn-close"><i class="fa fa-times"></i></a>
            </div>
        </div><!-- End Box Header Div-->
        <div class="box-content"><!-- Start Box Content Div-->
            <div class="row">
                <div class="col-sm-4">
                    
                    <?php 
                    if (isset($_GET['c_id'])) {
                        $select_single_course = "SELECT * FROM tbl_courses WHERE id = '" . $_GET['c_id'] . "'";
                        $course_query = mysql_query($select_single_course) or die(mysql_error());
                        if (mysql_num_rows($course_query)) {
                            $data = mysql_fetch_assoc($course_query);
                            $c_id = $_GET['c_id'];
                            $image_name = $data['course_image'];
                            $path =  SITE_URL."admin/dashboard/course_image/".$c_id."/".$c_id.".jpg";
                        }
                    }
                    if (isset($_GET['e_id'])) {
                        $select_single_course = "SELECT * FROM tbl_ebook WHERE id = '" . $_GET['e_id'] . "'";
                        $course_query = mysql_query($select_single_course) or die(mysql_error());
                        if (mysql_num_rows($course_query)) {
                            $data = mysql_fetch_assoc($course_query);
                            $c_id = $_GET['e_id'];
                            $image_name = $data['ebook_image'];
                            $path =  SITE_URL."admin/dashboard/ebook_images/".$c_id."/".$c_id.".jpg";
                        }
                    }
                    ?>
                    <img src="<?php echo $path; ?>" class="product_image" alt="Product Image">
                </div>
                <div class="col-sm-8">
                <!--/col-->
                
                    <?php
                    if (isset($_GET['c_id'])) {
                        $sel_session = "SELECT * FROM tbl_session WHERE trainee_id='" . $_SESSION['id'] . "' AND course_id='" . $_GET['c_id'] . "'";
                        $query_session = mysql_query($sel_session) or die(mysql_error());
                        $count_session = mysql_num_rows($query_session);

                        if (mysql_num_rows($query_session) > 0) {
                            $cnt_round = 0;
                            while ($row_session = mysql_fetch_array($query_session)) {
                                $select_trainer = "SELECT * FROM tbl_admin WHERE id='" . $row_session['trainer_id'] . "' AND is_active='1'";
                                $query_trainer = mysql_query($select_trainer) or die(mysql_error());
                                if (mysql_num_rows($query_trainer) > 0) {
                                    while ($row_trainer = mysql_fetch_array($query_trainer)) {


                                        $select_user_sch = "SELECT * FROM tbl_user_sel_sch_time WHERE trainer_id='" . $row_session['trainer_id'] . "' AND course_id='" . $_GET['c_id'] . "'AND trainee_id='" . $_SESSION['id'] . "' AND date(sch_date)>=date(now()) ORDER BY id DESC LIMIT 1";

                                        $query_user_sch = mysql_query($select_user_sch) or die(mysql_error());
                                        $count_trainer_session = mysql_num_rows($query_user_sch);
                                        if ($count_session == $count_trainer_session) {
                                            if (mysql_num_rows($query_user_sch) > 0) {
                                                if ($cnt_round < 1) {
                                                    echo '<div style="text-align:right; margin-right:5%; font-size:16px; color:blue; margin-bottom:-10px;">You can take one session with <a href="trainer_info.php?tr_id=' . $row_trainer['id'] . '">' . $row_trainer['Name'] . '</a></div>';
                                                }
                                                $cnt_round++;
                                            }
                                        } else {
                                            if ($cnt_round < 1) {
                                                echo '<div style="text-align:right; margin-right:5%; font-size:16px; color:blue; ">You can take one session with <a href="trainer_info.php?tr_id=' . $row_trainer['id'] . '">' . $row_trainer['Name'] . '</a></div>';
                                            }
                                            $cnt_round++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    ?>
                    <?php
                    if (isset($_GET['c_id'])) {
                        $select_single_course = "SELECT * FROM tbl_courses WHERE id = '" . $_GET['c_id'] . "'";
                        $course_query = mysql_query($select_single_course) or die(mysql_error());
                        if (mysql_num_rows($course_query)) {
                            while ($row_crs = mysql_fetch_array($course_query)) {
                                ?>
                                <div id="img_description">
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Name : </div>
                                        <div class="fl_left label_description"><?php echo $row_crs['course_name']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Description : </div>
                                        <div class="fl_left label_description"><?php echo $row_crs['course_description']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">From :</div>
                                        <div class="fl_left label_description"><?php echo $row_crs['course_from']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">TO :</div>
                                        <div class="fl_left label_description"><?php echo $row_crs['course_to']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Timing :</div>
                                        <div class="fl_left label_description"><?php echo $row_crs['course_timing']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Price :</div>
                                        <div class="fl_left label_description"><?php echo '$' . $row_crs['course_fee']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Files</div>
                                        <div class="fl_left label_description">
                                            <?php
                                            /*                                             * *************** create values for randomurl. starts here ************* */

                                            $alpha_arr = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
                                            $numeric_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');

                                            function array_random_assoc($arr, $num = 1) {
                                                $keys = array_keys($arr);
                                                shuffle($keys);

                                                $r = '';
                                                for ($i = 0; $i < $num; $i++) {
                                                    $r .= $arr[$keys[$i]];
                                                }
                                                return $r;
                                            }

                                            /*                                             * *************** create values for randomurl. ends here ************* */

                                            $select_ppt = "SELECT * FROM tbl_course_ppt WHERE course_id = '" . $_GET['c_id'] . "'";
                                            $query_ppt = mysql_query($select_ppt) or die(mysql_error());

                                            $rows = mysql_num_rows($query_ppt);
                                            $i = 0;
                                            if ($rows > 0) {
                                                while ($data = mysql_fetch_array($query_ppt)) {
                                                    /*                                                     * *************** call array_random_assoc function for create random number. starts here ************* */
                                                    $random_start_alpha_string = array_random_assoc($alpha_arr, 3);
                                                    $random_start_numeric_string = array_random_assoc($numeric_arr, 3);
                                                    $random_start_string = $random_start_alpha_string . $random_start_numeric_string;
                                                    $random_start_string = str_shuffle($random_start_string);

                                                    $random_end_alpha_string = array_random_assoc($alpha_arr, 3);
                                                    $random_end_numeric_string = array_random_assoc($numeric_arr, 3);
                                                    $random_end_string = $random_end_alpha_string . $random_end_numeric_string;
                                                    $random_end_string = str_shuffle($random_end_string);
                                                    /*                                                     * *************** call array_random_assoc function for create random number. ends here ************* */

                                                    //echo $data['file_name'].'  Random Start = '.$random_start_string.'      Random End = '.$random_end_string.'<br/>';
                                                    echo '<a href="view_ppt.php?value=' . $random_start_string . $_GET['c_id'] . '.' . $i . $random_end_string . '">' . $data['file_name'] . '</a><br/>';
                                                    $i++;
                                                }
                                            } else {
                                                echo 'No Files';
                                            }
                                            ?>
                                        </div>
                                        <div class="fl_clear"></div>
                                        <!--<a href="http://docs.google.com/viewer?url=http://onlinesalemanagement.com/online_sale/admin/dashboard/course_ppt/Hash/9_0.pptx">1 FIle</a>-->
                                    </div>
                                </div>
                                <?php
                            }
                        }
                    }
                    
                    if (isset($_GET['e_id'])) {
                        $select_single_course = "SELECT * FROM tbl_ebook WHERE id = '" . $_GET['e_id'] . "'";
                        $course_query = mysql_query($select_single_course) or die(mysql_error());
                        if (mysql_num_rows($course_query)) {
                            while ($row_crs = mysql_fetch_array($course_query)) {
                                $e_id = $_GET['e_id'];
                                $ebook_file = explode(".",$row_crs['ebook_file']);
                                $path_file =  SITE_URL."admin/dashboard/ebook_files/".$e_id."/".$e_id.".".$ebook_file[1];
                                ?>
                                <div id="img_description">
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Name : </div>
                                        <div class="fl_left label_description"><?php echo $row_crs['ebook_name']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Description : </div>
                                        <div class="fl_left label_description"><?php echo $row_crs['ebook_description']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                   
                                   
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Price :</div>
                                        <div class="fl_left label_description"><?php echo '$' . $row_crs['ebook_fee']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">File :</div>
                                        <div class="fl_left label_description">
                                            <?php if($row_crs['ebook_file'] != ''){?>
                                            <a href="<?php echo $path_file;?>" target="_blank">
                                            <label class="label label-info">View File</label>
                                            <?php }else{?>
                                                No file
                                                <?php }?>
                                            </a>
                                        </div>
                                        <div class="fl_clear"></div>
                                    </div>
                                 </div>
                                <?php
                            }
                        }
                    }
                    
                    ?>
                </div><!--/col-->
            </div><!-- End Row div -->
        </div><!-- End Box Content Div -->
    </div><!-- End Box Div-->
</div><!-- End Middle Content Div-->
<?php   if (isset($_GET['c_id'])) {
        ?>
<div class="col-lg-12"><!-- Start Middle Content Div-->
    <div class="box">
        <div class="box-header" data-original-title=""><!-- Start Box Header Div-->
            <h2><i class="fa fa-edit"></i><span class="break"></span>Trainer Info</h2>
            <div class="box-icon">
                <a href="gallery.html#" class="btn-minimize"><i class="fa fa-chevron-up"></i></a>
                <a href="gallery.html#" class="btn-close"><i class="fa fa-times"></i></a>
            </div>
        </div><!-- End Box Header Div-->
    
        <div class="box-content"><!-- Start Box Content Div-->
            <div class="row">
                <?php
                if (isset($_GET['c_id'])) {
                    $select_single_trainer = "SELECT * FROM tbl_trainee_schedule a
                        Left JOIN tbl_admin b ON a.trainer_id = b.id
                        WHERE a.course_id = '" . $_GET['c_id'] . "' and a.student_id = '".$_GET['u_detail']."'";
                    $course_trainer = mysql_query($select_single_trainer) or die(mysql_error());
                    if (mysql_num_rows($course_trainer)) {
                        while ($row_trainer = mysql_fetch_array($course_trainer)) {
                            $img_ext = $row_trainer['profile_image'];
                            if ($img_ext) {
                                $ext = explode(".", $img_ext);
                                $extension = end($ext);
                            }
                            ?>
                            <div class="col-sm-4">
                                <?php
                                if ($img_ext) {
                                    ?>
                                    <img src="<?php echo '../../admin/dashboard/profile_image/' . $row_trainer['id'] . '.' . $extension; ?>" class="product_image" alt="Product Image">
                                    <?php
                                } else {
                                    echo 'No Profile Image';
                                }
                                ?>
                            </div><!--/col-->
                            <div class="col-sm-8">

                                <div id="img_description">
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Name : </div>
                                        <div class="fl_left label_description"><?php echo $row_trainer['Name']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Email : </div>
                                        <div class="fl_left label_description"><?php echo $row_trainer['email']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Skype Email :</div>
                                        <div class="fl_left label_description"><?php echo $row_trainer['skype_mail']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Contact Number :</div>
                                        <div class="fl_left label_description"><?php echo $row_trainer['contact_number']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                    <div class="desc_row">
                                        <div class="fl_left label_heading">Address :</div>
                                        <div class="fl_left label_description"><?php echo $row_trainer['Address']; ?></div>
                                        <div class="fl_clear"></div>
                                    </div>
                                </div>
                                <?php
                            }
                        }
                    }
                    ?>
                </div><!--/col-->
            </div><!-- End Row div -->
        </div><!-- End Box Content Div -->
        
       
    </div><!-- End Box Div-->
</div><!-- End Middle Content Div-->

     <?php }?><?php include_once('footer.php'); ?>